This version of Shiny is designed to work with 'htmlwidgets' >= 1.5.
Please upgrade via install.packages('htmlwidgets').
primary_school %>%
group_by(continent, year) %>%
summarize(average = mean(primary_school)) %>%
ggplot(aes(x=year,y=average, color=continent)) +
geom_point() +
geom_line() +
labs(x="Year", y="Average Rate of Educational Attainment",
title = "Educational Attainment over Time by Continent")
world <- primary_school %>%
distinct(country)
map.world <- map_data("world")
world %>%
ggplot() +
geom_map(data = map.world, map = map.world,
aes(map_id = region), fill = "white", color = "black") +
geom_map(aes(map_id = country), map = map.world) +
expand_limits(x = map.world$long, y = map.world$lat) + # scale for fill
theme_map()
worldmap <- get_stamenmap(
bbox = c(left = -180, bottom = -57, right = 179, top = 82.1),
maptype = "toner-background",
zoom = 2
)
Source : http://tile.stamen.com/toner-background/2/0/0.png
Source : http://tile.stamen.com/toner-background/2/1/0.png
Source : http://tile.stamen.com/toner-background/2/2/0.png
Source : http://tile.stamen.com/toner-background/2/3/0.png
Source : http://tile.stamen.com/toner-background/2/0/1.png
Source : http://tile.stamen.com/toner-background/2/1/1.png
Source : http://tile.stamen.com/toner-background/2/2/1.png
Source : http://tile.stamen.com/toner-background/2/3/1.png
Source : http://tile.stamen.com/toner-background/2/0/2.png
Source : http://tile.stamen.com/toner-background/2/1/2.png
Source : http://tile.stamen.com/toner-background/2/2/2.png
Source : http://tile.stamen.com/toner-background/2/3/2.png
ggmap(worldmap)
primary_school %>%
filter(decade == 1990) %>%
group_by(decade, country) %>%
summarize(average = mean(child_mortality)) %>%
arrange(desc(average)) %>%
filter(country==c("Niger", "Costa Rica"))
longer object length is not a multiple of shorter object length
primary_school <- primary_school %>%
mutate(high_gdp = gdp_capita > 3955)
# scatterplots to find interactions between variables
ggplot(primary_school, aes(x=gdp_capita, y=unemployment, color=high_gdp)) + geom_point()
# linear regression
library(broom)
tidy(lm(primary_school ~ high_gdp + unemployment, data=primary_school))
tidy(lm(primary_school ~ gdp_capita + unemployment + child_mortality, data=primary_school))
tidy(lm(primary_school ~ gdp_capita + unemployment + rural_pop, data=primary_school))
# an interaction effect will let one variable affect the other. Doesn't mean that the two variables are related
# coeff 0 -> no relationship
# less variables to fit b/c NA
country_list <- primary_school %>%
select(1:1) %>%
distinct()
save(country_list,file="country_list.Rda")
## Map of World Educational Attainment
world <- primary_school %>%
filter(year==c("2014","2015")) %>%
distinct(country)
map.world <- map_data("world")
world %>%
ggplot() +
geom_map(data = map.world, map = map.world,
aes(map_id = region), fill = "white", color = "black") +
geom_map(aes(map_id = country), map = map.world) +
expand_limits(x = map.world$long, y = map.world$lat) + # scale for fill
theme_map()
worldmap <- get_stamenmap(
bbox = c(left = -180, bottom = -57, right = 179, top = 82.1),
maptype = "toner-background",
zoom = 2
)
ggmap(worldmap)
primary_school %>%
ggplot(aes(x=year, y=primary_school, color=high_gdp)) +
geom_jitter() +
facet_wrap(~ high_gdp) +
geom_smooth(se=FALSE)
plot <- ggplot(primary_school, aes(x=gdp_capita, y=primary_school, color=high_gdp)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
labs(x="GDP per capita", y="Educational Attainment (Primary School)",
title="Educational Attainment and GDP per Capita by Continent")
ggplotly(plot)
NA
##Schooling Cost Graph
ggplot(primary_school,aes(x=schooling_cost,y=primary_school, color=high_gdp))+
geom_point()+
geom_smooth(method="lm", se=FALSE)